home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The X-Philes (2nd Revision)
/
The X-Philes Number 1 (1995).iso
/
xphiles
/
hp48_2
/
rpl.unt
< prev
next >
Wrap
Internet Message Format
|
1991-04-12
|
39KB
From en.ecn.purdue.edu!noose.ecn.purdue.edu!samsung!zaphod.mps.ohio-state.edu!rpi!uupsi!sunic!liuida!ide10!d88joave 19 Feb 91 01:07:36 GMT
Path: en.ecn.purdue.edu!noose.ecn.purdue.edu!samsung!zaphod.mps.ohio-state.edu!rpi!uupsi!sunic!liuida!ide10!d88joave
From: d88joave@IDA.LiU.SE (Joakim A Verona)
Newsgroups: comp.sys.handhelds
Subject: RPL unthreader for HP48sx intro
Message-ID: <D88JOAVE.91Feb19020736@ide10.IDA.LiU.SE>
Date: 19 Feb 91 01:07:36 GMT
Sender: news@ida.liu.se (News Subsystem)
Distribution: comp
Organization: CIS Dept, University of Linkoping, Sweden
Lines: 281
Many people have expressed an interest in my HP48sx RPL unthreader, so
here it is!
The files are all in a shell archive, so just type 'sh _filename_' to
extract the following files:
unthread.c / main c prog
unthread.h / header file, containing constants used in unthread.c
readinf.c / The HP-internals file manager, owned by unthread.
hdump2hpbin / a program to convert hexdumps as given by the internal debugger
/ to HP-binay files.
makefile / to make the targets unthread and hdump2hpbin
You also need the HP internals file posted recently, to get the info
routines working. The file should be named 'hpint'.
#General information:
The purpose of all these programs are to facilitate the dissasembly of
the binary structure of RPL programs.
Type 'make' to make all targets.
I've only compiled and run the programs on a sun sparc station, but I
dont believe I use any magic, so they should run nicely on any
comparable system. If you encounter any problems, please try to find
where the problem lies, and inform me.
#About unthread:
To use unthread, download a binary file, and type 'unthread
_filename_'. You will be greeted by a display like this:
odal2 d88joave chaos 5>> unthread eqbin
Reading info
Scanning eqbin
reading 65544 bytes
File read ok
HPHP48-E
00010:02B40 LIBRARY |
00015:018DB size |
0001A:9460E libname | 'FIN :Finance'
0003A:0010E libnum |
0003D:01734 hash |
00042:0157C msg |
00047:017F1 link |
0004C:000DF config |
-- msg table --------------+
015BE:029E8 ARRAY |
015C3:00107 size |
015C8:02A2C STRING |
015CD:00001 #dims |
015D2:00007 dim |
-- array start ------------+
015D7:0001B size |
015DC:06F4E strdat | "No Solution"
015F2:0002D size |
015F7:E614D strdat | "Many or No Solutions"
0161F:00023 size |
01624:92549 strdat | "I%YR/PYR -100"
01642:00017 size |
01647:66E49 strdat | "Invalid N"
01659:0001B size |
0165E:66E49 strdat | "Invalid PYR"
01674:00025 size |
01679:66E49 strdat | "Invalid #Periods"
01699:00031 size |
0169E:46E55 strdat | "Undefined TVM Variable"
-- array end -------------+
-- hash table -------------+
01771:02A4E hashtable |
01776:000C2 size |
0177B:00000 hashoffs | Entry 0 nonexistant
01780:00000 hashoffs | Entry 1 nonexistant
01785:0004B hashoffs | Entry 2 at 17d0
0178A:00000 hashoffs | Entry 3 nonexistant
0178F:0004C hashoffs | Entry 4 at 17db
01794:00056 hashoffs | Entry 5 at 17ea
01799:00073 hashoffs | Entry 6 at 180c
0179E:00000 hashoffs | Entry 7 nonexistant
017A3:00000 hashoffs | Entry 8 nonexistant
017A8:00000 hashoffs | Entry 9 nonexistant
017AD:00000 hashoffs | Entry a nonexistant
017B2:00000 hashoffs | Entry b nonexistant
017B7:00000 hashoffs | Entry c nonexistant
017BC:00000 hashoffs | Entry d nonexistant
017C1:00000 hashoffs | Entry e nonexistant
017C6:00000 hashoffs | Entry f nonexistant
-- name table -------------+
017CB:00054 size |
00051:010E8 name entry | 'TVM'
017D8:00000 xlib |
00051:010E8 name entry | 'AMORT'
017E7:00004 xlib |
00051:010E8 name entry | 'TVMBEG'
017F8:00001 xlib |
00051:010E8 name entry | 'TVMEND'
01809:00002 xlib |
00051:010E8 name entry | 'TVMROOT'
0181C:00003 xlib |
-- Config for XLIB 270d ---+
0012B:02D9D PROGRAM | <<
00130:02911 SYSTEM_BINARY | <10e>
0013A:21C6F romobj | Internal ATTACH (1:Syst Bin)
0013F:0312B endprog | >>
-- link table -------------+
01838:02A4E linktable |
0183D:000AF size |
01842:FE816 linkoffs | xlib 0d at 58
01847:FE832 linkoffs | xlib 1d at 79
0184C:FE84D linkoffs | xlib 2d at 99
01851:FE86A linkoffs | xlib 3d at BB
01856:FE8B6 linkoffs | xlib 4d at 10C
0185B:FE8E9 linkoffs | xlib 5d at 144
01860:FEAC7 linkoffs | xlib 6d at 327
01865:FEAFB linkoffs | xlib 7d at 360
-- Code for XLIB 270d 0d --+
00058:02D9D PROGRAM | <<
0005D:18A1E romobj | save last RPL token, stack size, clear @706FD.S /= No_Args
00062:02E92 XLIB_NAME | XLIB 270d 5d
0006D:0312B endprog | >>
-- Code for XLIB 270d 1d --+
00079:02D9D PROGRAM | <<
0007E:18A1E romobj | save last RPL token, stack size, clear @706FD.S /= No_Args
00083:64BC6 romobj | <3Eh> /: Short_3eh
00088:53725 romobj | Set user flag (1:Syst Bin) /: Setflag_q
0008D:0312B endprog | >>
-- Code for XLIB 270d 2d --+
00099:02D9D PROGRAM | <<
0009E:18A1E romobj | save last RPL token, stack size, clear @706FD.S /= No_Args
000A3:64BC6 romobj | <3Eh> /: Short_3eh
000A8:53755 romobj | Clear user flag (1:Syst Bin) /= Clear_user_flag
000AD:0312B endprog | >>
-- Code for XLIB 270d 3d --+
000BB:02D9D PROGRAM | <<
000C0:18ECE romobj | Save last RPL token, verify DEPTH >= 1 and check args.
000C5:0402B romobj | <6h> /= Short_6
000CA:02E92 XLIB_NAME | XLIB 270d 31d
000D5:04053 romobj | <Ah> /= Short_0ah
000DA:02E92 XLIB_NAME | XLIB 270d 30d
000E5:0312B endprog | >>
-- Code for XLIB 270d 4d --+
0010C:02D9D PROGRAM | <<
00111:18ECE romobj | Save last RPL token, verify DEPTH >= 1 and check args.
00116:03FF9 romobj | <1h> /: Short_1
0011B:02E92 XLIB_NAME | XLIB 270d 9d
00126:0312B endprog | >>
-- Code for XLIB 270d 5d --+
00144:02D9D PROGRAM | <<
00149:06E97 romobj | Place next address on the stack, do not execute /: Get_value
0014E:02D9D PROGRAM | <<
00153:02A74 LIST | {
00158:02E48 GLOBAL_NAME | 'N'
00161:02E48 GLOBAL_NAME | 'I%YR'
00170:02E48 GLOBAL_NAME | 'PV'
0017B:02E48 GLOBAL_NAME | 'PMT'
00188:02E48 GLOBAL_NAME | 'FV'
00193:02A74 LIST | {
00198:02A2C STRING |
0019D:0000D size |
001A2:24D41 strdat | "AMRT"
001AA:02D9D PROGRAM | <<
001AF:3EE1A romobj | Not found
001B4:02E92 XLIB_NAME | XLIB 270d 4d
001BF:02E92 XLIB_NAME | XLIB 270d 8d
001CA:0312B endprog | >>
001CF:0312B endlist | }
001D4:02E48 GLOBAL_NAME | 'PYR'
001E1:02A74 LIST | {
001E6:02D9D PROGRAM | <<
001EB:40788 romobj | Null Program
001F0:02A2C STRING |
001F5:0000B size |
001FA:74542 strdat | "BEG"
00200:64BC6 romobj | <3Eh> /: Short_3eh
00205:53778 romobj | User flag set? (1:Syst Bin) -> True/False /: Test_user_flag
0020A:3EC99 romobj | Not found
0020F:0312B endprog | >>
00214:02D9D PROGRAM | <<
00219:3EE1A romobj | Not found
0021E:02E92 XLIB_NAME | XLIB 270d 1d
00229:02E92 XLIB_NAME | XLIB 270d 10d
00234:0312B endprog | >>
00239:0312B endlist | }
0023E:02A74 LIST | {
00243:02D9D PROGRAM | <<
00248:40788 romobj | Null Program
0024D:02A2C STRING |
00252:0000B size |
00257:44E45 strdat | "END"
0025D:64BC6 romobj | <3Eh> /: Short_3eh
00262:53778 romobj | User flag set? (1:Syst Bin) -> True/False /: Test_user_flag
00267:03AF2 romobj | Internal NOT (1:True/False) /: Not
0026C:3EC99 romobj | Not found
00271:0312B endprog | >>
00276:02D9D PROGRAM | <<
0027B:3EE1A romobj | Not found
00280:02E92 XLIB_NAME | XLIB 270d 2d
0028B:02E92 XLIB_NAME | XLIB 270d 11d
00296:0312B endprog | >>
0029B:0312B endlist | }
002A0:0312B endlist | }
002A5:06E97 romobj | Place next address on the stack, do not execute /: Get_value
002AA:02D9D PROGRAM | <<
002AF:02E92 XLIB_NAME | XLIB 270d 15d
002BA:3918A romobj | Not found
002BF:0312B endprog | >>
002C4:418D4 romobj | Store_7062d
002C9:151A6 romobj | Not found
002CE:06E97 romobj | Place next address on the stack, do not execute /: Get_value
002D3:02E92 XLIB_NAME | XLIB 270d 6d
002DE:41944 romobj | Store_7063c
002E3:06E97 romobj | Place next address on the stack, do not execute /: Get_value
002E8:02E92 XLIB_NAME | XLIB 270d 16d
002F3:41984 romobj | Store_70646
002F8:06E97 romobj | Place next address on the stack, do not execute /: Get_value
002FD:390A4 romobj | Not found
00302:419C4 romobj | Store_70655
00307:0312B endprog | >>
0030C:02E92 XLIB_NAME | XLIB 270d 15d
00317:40F86 romobj | Not found
0031C:0312B endprog | >>
Etc. I have cut out bits and pieces of the above. The first column
in the left field (infofield) is a nybble offset into the file, which
translates easily into addresses, according to the following formula:
startaddr+offset-16. The second column contains the data at that
address, in the reverse order of how it would appear in memory(see
below). The third collumn contains a label describing the data. If
it's a type descriptor the label apears in capitals. You would
probably need the Internals Guide by Dereck Nickel to find this
information useful. The right field contains an emulation of the HP
print format.
#About hdump2hpbin:
This program takes a hexdump in the format given by the internal
debugger i.e 80000:0123456789ABDCDE and turns it into a HP-binary
file, so you can look at it with unthread. Note that some Page_Magic
occurs when your in the debugger, so you can only look at the first
32Kb of portspace this way. You can of course use the various peek
routines available and download ROM that way if you like.
#About the code:
Okay, there is room for improvement here. I would greatly appreciate
any comments and concrete ideas for enhancment.
Some improvements I can think of that I might do someday includes
an info file for xlibs (XLIB 1792 2 is a rather cryptic name)
using hashtables instead of binary trees in the info section
(bintrees are rather inefective to insert sorted keys in)
(but I had the routines lying about)
dissasembly of machine language.
#About copyright and other boring stuff:
This program is of course Public Domain. You are hereby granted the
right to do whatever you please with these programs, as long as you
don't deprive any other sentient being(s) of the same right.
Especialy you may improve the code, and especialy especialy you may
send me those improvements.
You should also be aware that actually using these programs will
result in any sort of catastrophe up to and including the destruction
of the entire world as we know it. Notice that I didn't tell you to
use my programs above, merely how to.
--
==============================================================================
! Joakim Verona LiTH ! Snail: soergaardsgatan 11 ! Email: !
! Voice: 013/178107 ! 58239 Linkoeping ! d88joave@kolix.ida.liu.se !
==============================================================================
--
==============================================================================
! Joakim Verona LiTH ! Snail: soergaardsgatan 11 ! Email: !
! Voice: 013/178107 ! 58239 Linkoeping ! d88joave@kolix.ida.liu.se !
==============================================================================
From en.ecn.purdue.edu!noose.ecn.purdue.edu!samsung!zaphod.mps.ohio-state.edu!rpi!uupsi!sunic!liuida!ide10!d88joave 19 Feb 91 01:10:13 GMT
Path: en.ecn.purdue.edu!noose.ecn.purdue.edu!samsung!zaphod.mps.ohio-state.edu!rpi!uupsi!sunic!liuida!ide10!d88joave
From: d88joave@IDA.LiU.SE (Joakim A Verona)
Newsgroups: comp.sys.handhelds
Subject: RPL unthreader for HP48sx source
Message-ID: <D88JOAVE.91Feb19021013@ide10.IDA.LiU.SE>
Date: 19 Feb 91 01:10:13 GMT
Sender: news@ida.liu.se (News Subsystem)
Distribution: comp
Organization: CIS Dept, University of Linkoping, Sweden
Lines: 1027
#! /bin/sh
# This is a shell archive. Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file". To overwrite existing
# files, type "sh file -c". You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g.. If this archive is complete, you
# will see the following message at the end:
# "End of shell archive."
# Contents: hdump2hpbin.c makefile readinf.c unthread.c unthread.h
# Wrapped by projpd@majestix on Tue Feb 19 02:01:45 1991
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f hdump2hpbin.c -a "${1}" != "-c" ; then
echo shar: Will not over-write existing file \"hdump2hpbin.c\"
else
echo shar: Extracting \"hdump2hpbin.c\" \(953 characters\)
sed "s/^X//" >hdump2hpbin.c <<'END_OF_hdump2hpbin.c'
X#include <stdio.h>
X#include <sys/types.h>
X#include <sys/stat.h>
X#include <fcntl.h>
X
X
X/*******************************/
X/* takes a hp48 memdump as */
X/* given by the internal debugger */
X/* and turns it into a binary */
X/* file. */
X/*******************************/
X
X
X
X
Xunsigned char swap_n(c)
X unsigned char c;
X{
X return((c>>4)+(c<<4));
X}
X
Xint noteof()
X{
X
X int inp=getchar();
X ungetc(inp, stdin);
X return(inp!=EOF);
X}
X
Xmain()
X{
X int loop, intc;
X int flg=!EOF;
X long f1, f2;
X unsigned char sep;
X unsigned char cout;
X printf("HPHP48-E");
X while (noteof())
X {
X flg=scanf("%*[^0-9a-fA-F]");
X
X scanf("%5x%c%", &f1, &sep);
X /*printf(" flg:%d ", flg);*/
X
X /* printf("%x%c%", f1, sep);*/
X if (noteof())
X for (loop=0; loop<8; loop++)
X {
X scanf("%2x", &intc);
X cout=0xff&(unsigned char)intc;
X
X /* printf("%2x",cout);*/
X putchar(swap_n(cout));
X
X }
X }
X}
X
X
X
X
X
X
X
X
X
X
X
END_OF_hdump2hpbin.c
if test 953 -ne `wc -c <hdump2hpbin.c`; then
echo shar: \"hdump2hpbin.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f makefile -a "${1}" != "-c" ; then
echo shar: Will not over-write existing file \"makefile\"
else
echo shar: Extracting \"makefile\" \(161 characters\)
sed "s/^X//" >makefile <<'END_OF_makefile'
XCFLAGS = -g
Xunthread: unthread.o unthread.h readinf.o
X cc -o unthread unthread.o readinf.o
Xhdump2hpbin: hdump2hpbin.c
X cc -o hdump2hpbin hdump2hpbin.c
X
X
X
X
X
X
X
X
X
X
END_OF_makefile
if test 161 -ne `wc -c <makefile`; then
echo shar: \"makefile\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f readinf.c -a "${1}" != "-c" ; then
echo shar: Will not over-write existing file \"readinf.c\"
else
echo shar: Extracting \"readinf.c\" \(2040 characters\)
sed "s/^X//" >readinf.c <<'END_OF_readinf.c'
X#include <stdio.h>
X#include <sys/types.h>
X#include <fcntl.h>
X#include <strings.h>
X
X#define NIL NULL
X#define SMALLEST -1
X
X
X typedef struct bintree
X{
X int key;
X char *data;
X struct bintree *left, *right;
X};
X
Xstruct bintree *inforoot;
X
Xstruct bintree *makenode()
X{
X struct bintree *retval=(struct bintree *)malloc(sizeof(struct bintree));
X retval->left=NIL;
X retval->right=NIL;
X retval->key=SMALLEST;
X return(retval);
X}
X
X
Xinsert_node(root, key, data)
X struct bintree *root;
X char *data;
X int key;
X{
X struct bintree **nodehead=&(root->right);
X while ((*nodehead)!=NIL && ((*nodehead)->key!=key))
X nodehead= (( (*(*nodehead)).key)<key) ? &((*(*nodehead)).left):&((*(*nodehead)).right);
X if (*nodehead==NIL)
X *nodehead=makenode();
X (*nodehead)->key=key;
X (*nodehead)->data=data;
X}
X
Xstruct bintree *find_node(root, key)
X struct bintree *root;
X int key;
X{
X struct bintree **nodehead=&(root->right);
X while ((*nodehead)!=NIL && ((*nodehead)->key!=key))
X nodehead= (( (*(*nodehead)).key)<key) ? &((*(*nodehead)).left):&((*(*nodehead)).right);
X return(*nodehead);
X}
X
X
X
Xint noteof(file)
X FILE *file;
X{
X return(!feof(file));
X};
X
Xstruct bintree *read_infofile(name)
X char * name;
X{
X FILE *infile;
X int flag=1, n, cur_key;
X struct bintree *myroot=makenode();
X char *cur_line;
X infile = fopen(name, "r");
X if (infile)
X while(noteof(infile))
X {
X cur_line=(char *)malloc(80);
X while (noteof(infile)&&(0==fscanf(infile, "%x%*c%*[ ]%[^\n]", &cur_key, cur_line)))
X fscanf(infile, "%*[^\n]");
X if(noteof(infile))
X {
X insert_node(myroot, cur_key, cur_line);
X
X }
X }
X else
X printf("I told you to have a 'hpint' file!\nBut there is none..\n");
X return(myroot);
X}
X
X
X
X
X
Xchar *get_infostr(key)
X int key;
X{
X struct bintree *found_node;
X found_node=find_node(inforoot, key);
X if (found_node==NIL)
X return("Not found");
X else
X return( found_node->data );
X}
X
X
Xvoid init_info()
X{
X printf("Reading info\n");
X inforoot=read_infofile("hpint");
X
X}
X
X
X
X
X
X
X
X
X
X
X
END_OF_readinf.c
if test 2040 -ne `wc -c <readinf.c`; then
echo shar: \"readinf.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f unthread.c -a "${1}" != "-c" ; then
echo shar: Will not over-write existing file \"unthread.c\"
else
echo shar: Extracting \"unthread.c\" \(17058 characters\)
sed "s/^X//" >unthread.c <<'END_OF_unthread.c'
X#include <stdio.h>
X#include <sys/types.h>
X#include <sys/stat.h>
X#include <fcntl.h>
X#include "unthread.h"
X
Xunsigned char *myfilearr; /* global array for file */
Xint indentlevel=0, myoffset; /* offset in nybbles */
X
X
X
X#define PROLOG_NOS 25
X
Xstruct
X{
X char *name, *printname;
X int addr, no;
X} prologinfo[PROLOG_NOS] =
X{
X { "UNKNOWN" ,"\n" , NULL , -1 },
X { "SYSTEM_BINARY","" , SYSTEM_BINARY , 20 },
X { "REAL_NUMBER" ,"" , REAL_NUMBER , 0 },
X { "LONG_REAL" ,"" , LONG_REAL , 21 },
X { "COMPLEX" ,"" , COMPLEX , 1 },
X { "LONG_COMPLEX" ,"" , LONG_COMPLEX , 22 },
X { "CHARACTER" ,"\n" , CHARACTER , 24 },
X { "ARRAY" ,"\n" , ARRAY , 3 },
X { "LINKED_ARRAY" ,"" , LINKED_ARRAY , 23 },
X { "STRING" ,"\n" , STRING , 2 },
X { "BINARY_INT" ,"\n" , BINARY_INT , 10 },
X { "LIST" ,"{\n" , LIST , 5 },
X { "DIRECTORY" ,"DIR\n" , DIRECTORY , 15 },
X { "ALGEBRAIC" ,"" , ALGEBRAIC , 9 },
X { "UNIT" ,"\n" , UNIT , 13 },
X { "TAGGED" ,"" , TAGGED , 12 },
X { "GRAPHIC" ,"\n" , GRAPHIC , 11 },
X { "LIBRARY" ,"\n" , LIBRARY , 16 },
X { "BACKUP" ,"\n" , BACKUP , 17 },
X { "LIBRARY_DATA" ,"\n" , LIBRARY_DATA , 26 },
X { "PROGRAM" ,"<<\n" , PROGRAM , 8 },
X { "CODE" ,"\n" , CODE , 25 },
X { "GLOBAL_NAME" ,"" , GLOBAL_NAME , 6 },
X { "LOCAL_NAME" ,"" , LOCAL_NAME , 7 },
X { "XLIB_NAME" ,"" , XLIB_NAME , 14 }
X};
X
X
X
Xunsigned char swap_n(c)
X unsigned char c;
X{
X return((c>>4)+(c<<4));
X}
X
Xvoid aargh(str)
X char *str;
X{
X printf("%s %s",str,"\nExiting.\n");
X
X exit(0);
X}
X
Xint readin(name)
X char *name;
X{
X int myfilesize;
X FILE *infile;
X int filed;
X struct stat buf;
X unsigned char *tfp;
X int tempc;
X if ((filed = open(name,O_RDONLY))==-1)
X aargh("Could not open file\n");
X if (fstat(filed, &buf)==-1)
X aargh("fstat error\n");
X printf("reading %u bytes\n",buf.st_size);
X if (!(myfilearr=(unsigned char *)malloc((unsigned)(myfilesize=(long)buf.st_size))))
X aargh("Could not allocate memory\n");
X tfp=myfilearr;
X infile=fdopen(filed, "r");
X while ((tempc=fgetc(infile))!=EOF)
X {
X tempc=(char)0xff&tempc;
X *(tfp++)=swap_n(tempc);
X }
X
X printf("File read ok\n");
X return(myfilesize);
X}
X
Xunsigned char get_n(start, offset)
X int offset;
X unsigned char*start;
X{
X unsigned char retval;
X retval=*(start+(offset>>1));
X retval=offset&0x1?retval&0xf:((retval&0xf0)>>4);
X return(retval);
X}
X
Xint get_bin5(start,offset)
X int offset;
X unsigned char *start;
X{
X int retval=0, loop;
X for(loop=0; loop<5; loop++)
X {
X
X retval+=(get_n(start,offset+loop)<<(4*loop));
X
X }
X return(retval);
X}
X
Xint get_bin2(start,offset)
X int offset;
X unsigned char *start;
X{
X int retval=0, loop;
X for(loop=0; loop<2; loop++)
X {
X
X retval+=(get_n(start,offset+loop)<<(4*loop));
X
X }
X return(retval);
X}
X
Xint get_binx(binxstart, offset, nonib)
X unsigned char *binxstart;
X int offset,nonib;
X{
X int retval=0, loop;
X for(loop=0; loop<nonib; loop++)
X {
X
X retval+=(get_n(binxstart,offset+loop)<<(4*loop));
X
X }
X return(retval);
X}
X
Xint print_hps(start, offset, length)
X unsigned char *start;
X int offset, length;
X{
X int loop;
X for (loop=0; loop<(length*2); loop+=2)
X {
X printf ("%c",get_binx(start, offset+loop, (int)2));
X }
X return(length*2);
X}
X
Xint find_prolog(prolog)
X int prolog;
X{
X int loop;
X
X for (loop=1; loop<PROLOG_NOS; loop++)
X if (prologinfo[loop].addr==prolog) return(loop);
X return(0); /* unsuccesful */
X}
X
X
Xint print_size(start, offset)
X unsigned char *start;
X int offset;
X{
X print_beg(start, offset, 5, "size", FORCE_NL);
X return(5);
X}
X
Xint print_ascix(start, offset)
X unsigned char *start;
X int offset;
X{
X int strlen=get_bin2(start, offset);
X if (strlen!=0)
X {
X printf("'");
X print_hps(start, offset+2, strlen);
X puts("'");
X return(4+strlen*2);
X }
X else
X {
X printf("''\n");
X return(2);
X }
X}
X
Xint print_ascic(start, offset)
X unsigned char *start;
X int offset;
X{
X int strlen=get_bin2(start, offset);
X if (strlen!=0)
X {
X printf("'");
X print_hps(start, offset+2, strlen);
X puts("'");
X return(2+strlen*2);
X }
X else
X {
X printf("''\n");
X return(2);
X }
X}
X
X
Xvoid pr_infh(n)
X int n;
X{
X printf(" ");
X n=INFOFIELD_L-n-1+12;
X while((n--)>0)
X printf("-");
X printf("+\n");
X}
X
X
Xint print_string(start, offset)
X unsigned char *start;
X int offset;
X{
X int length=get_binx(start, offset, 5);
X print_size(start, offset);
X print_beg(start, offset+5, 5, "strdat", indentlevel);
X printf("\"");
X print_hps(start, offset+5, (length-5)/2);
X printf("\"\n");
X return(length);
X}
X
Xint print_binint(start, offset)
X unsigned char *start;
X int offset;
X{
X int loop, length=get_bin5(start, offset);
X
X offset+=print_size(start, offset);
X print_beg(start, offset, 5, "binintdata", indentlevel);
X printf("#");
X for(loop=0; loop<(length-5); loop++)
X printf("%X", get_n(start, offset+loop));
X printf("h\n");
X return(length);
X}
X
Xint print_real(start, offset)
X unsigned char *start;
X int offset;
X{
X return(print_realx(start, offset, REAL_FORM12));
X}
X
X
X
Xint print_realx(start, offset, length)
X unsigned char *start;
X int offset, length;
X{
X int loop;
X float cf;
X char gonzaga[20];
X char *gonz=gonzaga;
X if (get_n(start, offset+length-1)==MAGIC_MINUS)
X sprintf(gonz++, "-");
X sprintf(gonz, "%X.", get_n(start, offset+length-2));
X gonz+=2;
X for(loop=length-3; loop>=0; loop--)
X {
X if (loop==2)
X sprintf(gonz++, "E");
X
X sprintf(gonz++, "%X", get_n(start, offset+loop));
X }
X sscanf(gonzaga, "%f", &cf);
X printf("%g", cf);
X printf(" ");
X return(length);
X}
X
X
Xint print_complex(start, offset)
X unsigned char *start;
X int offset;
X{
X return(print_complexx(start, offset, REAL_FORM12));
X}
X
Xint print_complexx(start, offset, form)
X unsigned char *start;
X int offset, form;
X{
X printf("Re:");
X offset+=print_realx(start, offset, form);
X printf("Im:");
X offset+=print_realx(start, offset, form);
X
X return(2*form);
X}
X
X
Xint print_graphic(start, offset)
X unsigned char *start;
X int offset;
X{
X int rows, cols, length;
X print_size(start, offset);
X length=get_bin5(start, offset);
X offset+=5;
X print_beg(start, offset, 5, "#rows", FORCE_NL);
X rows=get_bin5(start, offset);
X offset+=5;
X print_beg(start, offset, 5, "#columns", FORCE_NL);
X cols=get_bin5(start, offset);
X offset+=5;
X print_beg(start, offset, 5, "grdat", FORCE_NL);
X pr_infh(WHOLE_INFOFIELD);
X print_sillygraph(start, offset, rows, cols);
X pr_infh(WHOLE_INFOFIELD);
X return(length);
X}
X
Xint print_sillygraph(start, offset, rows, cols)
X unsigned char *start;
X int offset, rows, cols;
X{
X int rowloop, colloop, nloop, nstr;
X cols=cols/4+((cols%4)?1:0);
X cols=cols+((cols%2)?1:0);
X for (rowloop=0; rowloop<rows; rowloop++)
X {
X for (colloop=0; colloop<cols; colloop++)
X {
X nstr=get_n(start, offset++);
X for (nloop=0; nloop<4; nloop++)
X if (nstr&(1<<nloop))
X printf("#");
X else
X printf(" ");
X }
X puts("");
X }
X puts("");
X}
X
Xint print_librarydata(start, offset)
X unsigned char *start;
X int offset;
X{
X int oldoffs=offset;
X offset+=print_size(start, offset);
X offset+=print_beg(start, offset, 3, "libno", FORCE_NL);
X offset+=print_beg(start, offset, 2, "datano", FORCE_NL);
X
X while (get_binx(start, offset, 5)!=END_OF_LIBRARYDATA)
X offset+=print_block(start, offset);
X offset+=print_beg(start, offset, 5,"endlibdat", FORCE_NL);
X return(offset-oldoffs);
X}
X
X
X
Xvoid print_spx(no)
X int no;
X{
X while((no--)>0)
X putchar(32);
X}
X
X
Xint print_beg(start, offset, nybbles, typestr, ind)
X int offset, nybbles, ind;
X char *typestr;
X unsigned char *start;
X{
X printf("%05.X:%05.X %s", offset, get_binx(start, offset, nybbles) , typestr);
X print_spx(INFOFIELD_L-strlen(typestr));
X printf("|");
X if (ind==FORCE_NL)
X puts("");
X else
X print_spx(ind);
X
X return(nybbles);
X
X}
X
Xint print_algebraic(start, offset)
X unsigned char *start;
X int offset;
X{
X while (get_binx(start, offset, 5)!=END_OF_ALGEBRAIC)
X offset+=print_block(start, offset);
X offset+=print_beg(start, offset, 5,"endalg", indentlevel);
X
X}
Xint print_obj(start, offset, cur_prolog)
X unsigned char *start;
X int offset, cur_prolog;
X{
X int print_block();
X int print_arry();
X int endoffs, oldoffs=offset;
X
X switch (cur_prolog)
X {
X case BACKUP :
X offset+=print_size(start, offset);
X print_beg(start, offset, 5, "backupname", indentlevel);
X offset+=print_ascix(start, offset);
X offset+=print_block(start, offset);
X break;
X case DIRECTORY :
X offset+=print_beg(start, offset, 3, " attach", FORCE_NL);
X (void)print_beg(start, offset, 5, " offset1", FORCE_NL);
X endoffs=offset+get_binx(start, offset, 5);
X offset+=5;
X do
X {
X offset+=print_beg(start, offset, 5, " offset", FORCE_NL);
X print_beg(start, offset, 5, "DIRENTRY", indentlevel);
X offset+=print_ascix(start, offset);
X offset+=print_block(start, offset);
X }
X while (offset < endoffs );
X break;
X
X case BINARY_INT :
X offset+=print_binint(start, offset);
X break;
X case LIST:
X while (get_binx(start, offset, 5)!=END_OF_LIST)
X offset+=print_block(start, offset);
X offset+=print_beg(start, offset, 5,"endlist", indentlevel);
X printf("}\n");
X break;
X case PROGRAM:
X while (get_binx(start, offset, 5)!=END_OF_PROGRAM)
X offset+=print_block(start, offset);
X offset+=print_beg(start, offset, 5,"endprog", indentlevel);
X printf(">>\n");
X break;
X case LOCAL_NAME:
X offset+=print_ascic(start, offset);
X break;
X case GLOBAL_NAME:
X offset+=print_ascic(start, offset);
X break;
X case STRING:
X offset+=print_string(start, offset);
X break;
X case REAL_NUMBER:
X offset+=print_real(start, offset);
X break;
X case COMPLEX:
X offset+=print_complex(start, offset);
X break;
X case LONG_REAL:
X offset+=print_realx(start, offset, REAL_FORM15);
X break;
X case LONG_COMPLEX:
X offset+=print_complexx(start, offset, REAL_FORM15);
X break;
X case ARRAY:
X offset+=print_array(start, offset);
X break;
X case LIBRARY :
X offset+=print_library(start, offset);
X break;
X case XLIB_NAME :
X offset+=print_xlibname(start, offset);
X break;
X case SYSTEM_BINARY :
X printf("<%x>\n", get_bin5(start, offset));
X offset+=5;
X break;
X case CODE :
X print_size(start, offset);
X offset+=get_bin5(start, offset);
X printf("No dissasembly yet!\n");
X break;
X case GRAPHIC :
X offset+=print_graphic(start, offset);
X break;
X case CHARACTER :
X print_beg(start, offset, 2, "char", indentlevel);
X printf("'%c'\n", get_binx(start, offset, 2));
X offset+=2;
X break;
X case LINKED_ARRAY :
X print_beg(start, offset, 5, "size", indentlevel);
X printf("I dont know how to display this form.\n");
X offset+=get_bin5(start, offset);
X case ALGEBRAIC :
X offset+=print_algebraic(start, offset);
X break;
X case LIBRARY_DATA :
X offset+=print_librarydata(start, offset);
X break;
X case TAGGED :
X offset+=print_ascic(start, offset);
X offset+=print_block(start, offset);
X break;
X case UNIT :
X offset+=print_block(start, offset);
X offset+=print_block(start, offset);
X while (get_binx(start, offset, 5)!=END_OF_TAG)
X offset+=print_block(start, offset);
X offset+=print_beg(start, offset, 5,"endunit", FORCE_NL);
X break;
X }
X return(offset-oldoffs);
X}
X
X
Xint print_array(start, offset)
X unsigned char *start;
X int offset;
X{
X int cur_prolog_no, length, obj_nos=1, dims, cur_prolog;
X print_size(start, offset);
X length=get_bin5(start, offset);
X offset+=5;
X cur_prolog=get_bin5(start, offset);
X cur_prolog_no=find_prolog(cur_prolog);
X print_beg(start, offset, 5, prologinfo[cur_prolog_no].name , FORCE_NL);
X offset+=5;
X print_beg(start, offset, 5, "#dims ", FORCE_NL);
X dims=get_bin5(start, offset); offset+=5;
X while(dims--)
X {
X print_beg(start, offset, 5, "dim", FORCE_NL);
X obj_nos*=get_bin5(start, offset);
X offset+=5;
X }
X pr_infh(printf("-- array start"));
X while(obj_nos--)
X offset+=print_obj(start, offset, cur_prolog);
X pr_infh(printf("\n-- array end"));
X return(length);
X}
X
Xint print_xlibname(start, offset)
X unsigned char *start;
X int offset;
X{
X printf("XLIB %dd %dd\n", get_binx(start, offset, 3), get_binx(start, offset+3, 3));
X return(XLIBNAME_L);
X}
X
X
X
Xint print_library(start, offset)
X unsigned char *start;
X int offset;
X{
X int *linkme, *linkbase, oldoffs=offset;
X int lts, nts, loop, loop2;
X struct {
X int libno, hashoffs, msgoffs, linkoffs, configoffs
X } libinfo;
X int length=get_bin5(start, offset);
X offset+=print_size(start, offset);
X print_beg(start, offset, 5, "libname", indentlevel);
X offset+=print_ascix(start, offset);
X print_beg(start, offset, 3, "libnum", FORCE_NL);
X libinfo.libno=get_binx(start, offset, 3);
X offset+=3;
X
X print_beg(start, offset, 5, "hash", FORCE_NL);
X libinfo.hashoffs=get_bin5(start, offset)+offset;
X offset+=5;
X
X print_beg(start, offset, 5, "msg", FORCE_NL);
X libinfo.msgoffs=get_bin5(start, offset)+offset;
X offset+=5;
X
X print_beg(start, offset, 5, "link", FORCE_NL);
X libinfo.linkoffs=get_bin5(start, offset)+offset;
X offset+=5;
X
X print_beg(start, offset, 5, "config", FORCE_NL);
X libinfo.configoffs=get_bin5(start, offset)+offset;
X offset+=5;
X
X if (libinfo.msgoffs!=0x24+oldoffs)
X {
X pr_infh(printf("-- msg table"));
X print_block(start, libinfo.msgoffs);
X }
X
X pr_infh(printf("-- hash table"));
X libinfo.hashoffs+=print_beg(start, libinfo.hashoffs, 5, "hashtable", FORCE_NL);
X libinfo.hashoffs+=print_size(start, libinfo.hashoffs);
X for (loop=0; loop<16; loop++)
X {
X print_beg(start, libinfo.hashoffs, 5, "hashoffs", indentlevel);
X printf("Entry %x", loop);
X if (get_bin5(start, libinfo.hashoffs) != 0)
X printf(" at %x\n", libinfo.hashoffs+get_bin5(start, libinfo.hashoffs));
X else
X printf(" nonexistant\n");
X libinfo.hashoffs+=5;
X }
X pr_infh(printf("-- name table"));
X print_size(start, libinfo.hashoffs);
X nts=libinfo.hashoffs+get_bin5(start, libinfo.hashoffs);
X libinfo.hashoffs+=5;
X while(nts>libinfo.hashoffs)
X {
X print_beg(start, offset, 5, "name entry", indentlevel);
X libinfo.hashoffs+=print_ascic(start, libinfo.hashoffs);
X libinfo.hashoffs+=print_beg(start, libinfo.hashoffs, 3, "xlib", FORCE_NL);
X }
X pr_infh(printf("-- Config for XLIB %dd", libinfo.libno));
X print_block(start, libinfo.configoffs);
X
X pr_infh(printf("-- link table"));
X libinfo.linkoffs+=print_beg(start, libinfo.linkoffs, 5, "linktable", FORCE_NL);
X print_size(start, libinfo.linkoffs);
X lts=get_bin5(start, libinfo.linkoffs);
X linkbase=(int *)malloc((lts/5)*sizeof(int));
X linkme=linkbase;
X libinfo.linkoffs+=5;
X loop=0;
X while((lts-=5)>0)
X {
X print_beg(start, libinfo.linkoffs, 5, "linkoffs", indentlevel);
X *linkme++=(get_bin5(start, libinfo.linkoffs)+libinfo.linkoffs)&FIVENYBLES;
X printf("xlib %dd at %X\n", loop,*(linkme-1));
X libinfo.linkoffs+=5;
X loop++;
X }
X linkme=linkbase;
X for (loop2=0; loop2<loop; loop2++)
X {
X pr_infh(printf("-- Code for XLIB %dd %dd", libinfo.libno, loop2));
X print_block(start, *linkme++);
X }
X free(linkbase);
X return(length);
X}
X
X
X
Xint print_block(start, offset)
X unsigned char *start;
X int offset;
X{
X int oldoff=offset;
X int cur_prolog=get_bin5(start, offset);
X int cur_prolog_no=find_prolog(cur_prolog);
X indentlevel+=2;
X
X if (cur_prolog_no!=0)
X {
X print_beg(start, offset, 5, prologinfo[cur_prolog_no].name , indentlevel);
X printf("%s", prologinfo[cur_prolog_no].printname);
X offset+=5;
X offset+=print_obj(start, offset, cur_prolog);
X }
X else
X {
X print_beg(start, offset, 5, "romobj" , indentlevel);
X printf("%s", get_infostr(cur_prolog));
X puts("");
X offset+=5;
X
X }
X indentlevel-=2;
X return(offset-oldoff);
X}
X
X
Xmain(argc,argv)
X int argc;
X char *argv[];
X{
X int retval, filesize=0;
X init_info();
X
X if (argc==2)
X printf("Scanning %s\n", argv[1]);
X else
X printf("erraneous arguments\n");
X filesize=readin(argv[1]);
X myoffset+=print_hps(myfilearr, myoffset, 8);
X printf("\n");
X while ((2*filesize)>myoffset)
X {
X myoffset+=print_block(myfilearr, myoffset);
X }
X printf("\n\n####END\n");
X}
END_OF_unthread.c
if test 17058 -ne `wc -c <unthread.c`; then
echo shar: \"unthread.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f unthread.h -a "${1}" != "-c" ; then
echo shar: Will not over-write existing file \"unthread.h\"
else
echo shar: Extracting \"unthread.h\" \(1006 characters\)
sed "s/^X//" >unthread.h <<'END_OF_unthread.h'
X
X#define SYSTEM_BINARY 0x02911
X#define REAL_NUMBER 0x02933
X#define LONG_REAL 0x02955
X#define COMPLEX 0x02977
X#define LONG_COMPLEX 0x0299d
X#define CHARACTER 0x029bf
X#define ARRAY 0x029e8
X#define LINKED_ARRAY 0x02a0a
X#define STRING 0x02a2c
X#define BINARY_INT 0x02a4e
X#define LIST 0x02a74
X#define DIRECTORY 0x02a96
X#define ALGEBRAIC 0x02ab8
X#define UNIT 0x02ada
X#define TAGGED 0x02afc
X#define GRAPHIC 0x02b1e
X#define LIBRARY 0x02b40
X#define BACKUP 0x02b62
X#define LIBRARY_DATA 0x02b88
X#define PROGRAM 0x02d9d
X#define CODE 0x02dcc
X#define GLOBAL_NAME 0x02e48
X#define LOCAL_NAME 0x02e6d
X#define XLIB_NAME 0x02e92
X
X#define FORCE_NL -1
X#define FIVENYBLES 0xfffff
X#define INFOFIELD_L 15
X#define WHOLE_INFOFIELD 0
X
X
X#define REAL_L 16
X#define XLIBNAME_L 6
X
X#define REAL_FORM12 16
X#define REAL_FORM15 19
X#define MAGIC_MINUS 9
X
X#define END_OF_LIST 0x0312b
X#define END_OF_ALGEBRAIC 0x0312b
X#define END_OF_PROGRAM 0x0312b
X#define END_OF_LIBRARYDATA 0x0312b
X#define END_OF_TAG 0x0312b
X
X
X
X
X
END_OF_unthread.h
if test 1006 -ne `wc -c <unthread.h`; then
echo shar: \"unthread.h\" unpacked with wrong size!
fi
# end of overwriting check
fi
echo shar: End of shell archive.
exit 0
--
==============================================================================
! Joakim Verona LiTH ! Snail: soergaardsgatan 11 ! Email: !
! Voice: 013/178107 ! 58239 Linkoeping ! d88joave@kolix.ida.liu.se !
==============================================================================
--
==============================================================================
! Joakim Verona LiTH ! Snail: soergaardsgatan 11 ! Email: !
! Voice: 013/178107 ! 58239 Linkoeping ! d88joave@kolix.ida.liu.se !
==============================================================================